﻿<?php
$this->lang->load('template');
$this->load->view('admin/common/header',array('_user'=>$_user,'modules'=>$modules,'pageTitle'=>'用户管理'));
$user = array(
	'attr' => array(
		'class' => 'index'
	),
	'fields' => array(
		'id' => array('label'=>$this->lang->line('tpl_userid'),'is_sort'=>true),
		'username' => array('label' => $this->lang->line('tpl_username'),'is_sort'=>true),
		'email'	=> array('label'=>$this->lang->line('tpl_email')),
		'is_activated' => array('label' => $this->lang->line('tpl_isactive'),'filter'=>'_doFilter','is_sort'=>true ),
		'is_locked' => array('label' => $this->lang->line('tpl_islocked'),'filter'=>'_doFilter','is_sort'=>true ),
		//'is_admin' => array('label' => __('feild.is_admin') ,'filter'=>'_doFilter','is_sort'=>true ),
  		'action'	=> array('label' => $this->lang->line('tpl_actions'),'filter'=>'__doFilter'  ),
	),
	'data' => $result['result'],
);
function _doFilter($f,$r){
	if(substr($f,0,2)=='is'){
		return sprintf('<img src="%s">',__st($r[$f]));
	}
	return $r[$f];
}
function __doFilter($f,$r){
	//$str = $r[$f];
	if($f=='action'){
		$str = '<a href="%s" class="edit_image_link" title="编辑"><img alt="Edit" src="'.base_url('images/admin/icons/edit.png').'" /></a>';
		$str .= '&nbsp;';
		$str .= '<a href="%s" class="remove_link" rel="'.$r['id'].'" title="删除"><img alt="Remove" src="'.base_url('images/admin/icons/delete.png').'" /></a>';
		return sprintf($str,base_url('admin/users/edit/'.$r['id']),base_url('admin/users/remove/'.$r['id']));
	}
}
?>

<script language="javascript">
$(document).ready(function(){
	$('.remove_link').click(
		function(event){
			event.preventDefault();
			url = this.href+'?format=json';
			return Admin.remove(
				url,
				'您确定删除该数据吗？'
			);
		}
	);
	$('.sort_link').click(
		function(event){
			event.preventDefault();
			field = this.attributes['field'].value;;
			return urlRequest.setSort(field);
		}
	);
});
</script>
<div class="clear with-sidebar" id="content">
  <div class='toolbar'>
   <ul class='actions'>
      <li> <a href="<?=site_url('admin/users/create')?>" class="button" id="new_item_link"><span><img alt="Add" src="<?=base_url('images/admin/icons/add.png')?>" /><?=$this->lang->line('tpl_act_add')?></span></a> </li>
    </ul>
    <br class='clear' />
  </div>
  <h1><?=$this->lang->line('tpl_userlist')?> </h1>
  <?=htmlTable($user);?>
  <?php 
  	if (isset($result['pager'])) :
  ?>
  <div id="pagination" class="pagination"> 
  	<?php
  		echo $result['pager']->create_links();
  	?>
  </div>
  <?php endif;?>
  <br class='clear' />
  <div id="sidebar">
    <form method="get">
      <div class="box">
        <h3><?=$this->lang->line('tpl_user_search')?></h3>
        <p class="wrap_keyword"> <span class="label"><?=$this->lang->line('tpl_username')?></span> <br />
          <input id="form_id_keyword" name="keyword" type="text" value="<?=isset($_REQUEST['keyword'])?$_REQUEST['keyword']:''?>" />
          <span class="tips"> </span> </p>
        <p class="form-buttons">
          <button type="submit" class="btn"><span><?=$this->lang->line('tpl_submit')?></span></button>
        </p>
      </div>
      <div>
        <input type="hidden" name="sfield" id="form_idsfield" value="username" />
        <!--
	        <input type="hidden" name="stype" id="form_idstype" value="both" />
	        <input type="hidden" name="c" id="form_idc" value="users" />
	        <input type="hidden" name="a" id="form_ida" value="index" />
        -->
      </div>
    </form>
  </div>
</div>
<?php $this->load->view('admin/common/footer');?>